type GridInData = Array<{
    ORG_NAME: string;
    PARENT_NAME: string;
    COOR_ID: string;
    TDT_LNG: string;
    TDT_LAT: string;
}>;

export const handleGridData = (data: GridInData) => {
    const gridResult: { countryName: string; gridName: string; path: Path }[] = [];
    const result: { countryName: string; path: Path[] }[] = [];
    data.map(vo => {
        const item = gridResult.find(i => i.gridName === vo.ORG_NAME && i.countryName === vo.PARENT_NAME);
        if (item) {
            item.path.push([+vo.TDT_LAT, +vo.TDT_LNG]);
        } else {
            gridResult.push({ countryName: vo.PARENT_NAME, gridName: vo.ORG_NAME, path: [[+vo.TDT_LAT, +vo.TDT_LNG]] });
        }
    });

    gridResult.map(vo => {
        const item = result.find(i => i.countryName === vo.countryName);
        if (item) {
            item.path.push(vo.path);
        } else {
            result.push({ countryName: vo.countryName, path: [vo.path] });
        }
    });
    return result;
};

export const setCountryName = (name: string) => name.replace('村民委员会', '').replace('居民委员会', '');

// getGridData() {
//     this.showModal = true;
//     this.result = JSON.stringify(
//         this.polyEditor
//             .getTarget()
//             .getPath()
//             .map((vo: { lng: string; lat: string }) => [vo.lng, vo.lat])
//     );
// }
